package com.example.arithmeticleetcode.leetcode.nov;

/**
 * @program: arithmetic-leetcode
 * @description:
 * @author: FangZhen
 * @create: 2020-11-13 10:17
 **/
public class Demo08 {

    public static void main(String[] args) {
        int[][] arr = {{3,2},{-2,2}};
        System.out.println(minTimeToVisitAllPoints(arr));

        int[][] arr1 = {{3,2},{1, 1}};
        System.out.println(minTimeToVisitAllPoints(arr1));

        int[][] arr2 = {{3,2}};
        System.out.println(minTimeToVisitAllPoints(arr2));

        int i = 5;
        System.out.println(1 << i);
        System.out.println(i);
    }

    public static int minTimeToVisitAllPoints(int[][] points) {

        int result = 0;
        if (points.length < 2) {
            return result;
        }

        for (int i = 0, len = points.length - 1; i < len; i++) {
            int x = Math.abs(points[i][0] - points[i + 1][0]);
            int y = Math.abs(points[i][1] - points[i + 1][1]);
            result += (x > y ? x : y);
        }
        return result;
    }
}
